<?php

//header("Content-Type: text/html;charset=gbk");
        const SEND_URL = 'https://testebank.sdb.com.cn:461/corporbank/KH0001.pay';


require_once 'lib/pingan.php';
$pingan = new pingan();

$data = array(
    'masterId' => '2000311146',
    'orderId' => $_POST['order_id'],
);


$xml_data = $pingan->array_to_xml($data);
$merchantCertFile = 'merchant/2000311146.pfx';

//获取签名后的orig和sign
$orig = $pingan->getOrig($xml_data);
$sign = $pingan->getSign($merchantCertFile, $xml_data);

//通过curl请求接口
$parms = 'orig=' . $orig . '&sign=' . $sign;
$rsponse = $pingan->curl(SEND_URL, $parms);

//通过字符串截取获取orig
$rsponseData = explode('orig=', $rsponse);
$rsponse2Data = explode('SDBPAYGATE=', $rsponseData[1]);

//解码
$formOrig = $pingan->_base64_url_decode($rsponse2Data[0]);

//编码转换功能
$xml_dom = mb_convert_encoding($formOrig, "UTF-8", "GBK");

//转换为数组
$result = $pingan->xml_to_array($xml_dom);

//打印结果
print_r($result);